foitzik.dev // my collection of random things and thoughts

SHORTY Setting up a desktop with nvidia and a recent kernel

If you are like me and tried to install nixOS 25.05 and enabled nvidia and had problems with building the drivers and wanted a recent kernel/driver. This is what worked for me. And I find it quite elegant that you can just do hardware.nvidia.package = config.boot.kernelPackages.nvidiaPackages.beta;.

{ lib, config, pkgs, nixpkgs-unstable, inputs, ... }:

{
  imports =
    [ # Include the results of the hardware scan.
      ./hardware-configuration.nix
    ];

  # Bootloader.
  boot.loader.systemd-boot.enable = true;
  boot.loader.efi.canTouchEfiVariables = true;
  nix.settings.experimental-features = [ "nix-command" "flakes" ];

  # Use latest kernel.
  boot.kernelPackages = pkgs.linuxPackages;
  hardware.nvidia.package = config.boot.kernelPackages.nvidiaPackages.beta;
  hardware.graphics.enable = true;
  hardware.nvidia.open = true;
  services.xserver.videoDrivers = [ "nvidia" ];
}